<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title>phonegap_device_network_notification01</title>
<link href="../jquery.mobile-1.3.2.css" rel="stylesheet" type="text/css"/>
<script src="../jquery.js" type="text/javascript"></script>
<script src="../jquery.mobile-1.3.2.js" type="text/javascript"></script>
<script src="../cordova.js" type="text/javascript"></script>
<style>
#supportedMode{
    width: 288px; height: 100px;position:relative;border:1px solid #b8b8b8;
}
#message{
    width: 288px; height: 100px;position:relative;border:1px solid #b8b8b8;
}
#audiocontainer{
    width: 288px; height: 100px; position:relative;border:1px solid #b8b8b8;
}
</style>
 <script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
		  document.addEventListener("deviceready",onDeviceReady,false);
	});
    function onDeviceReady(){
     //   alert("device ready");
        $(".captureAudioBtn").click(function(){
        	navigator.device.capture.captureImage(captureSuccess, captureError, {limit:2});        	
        })
   
        
    }
  	//成功
  	function captureSuccess(mediaFiles){
  		var i;
  		for(i=0;i<mediaFiles.length;i++){
  			var fullPath= mediaFiles[i].fullPath;
  			var name= mediaFiles[i].name
  			/*
  				console.log('第'+i+'张图片');
  			console.log('fullPath'+fullPath);
  			console.log('name'+name);
  			console.log("type--->" + mediaFiles[i].type);
 			console.log("lastModifiedDate--->" + mediaFiles[i].lastModifiedDate);
 			console.log("size--->" + mediaFiles[i].size);
  			*/
  			$('#message').append('fullPath->'+fullPath+','+'name->'+name+'<br>');
  			 $("#imgcontainer").append("<img width=300 height=300  src='"+fullPath+"' />");
  		
  		}
  	}
  	
    //失败的回调函数
    function captureError(error) {
        var msg = 'An error occurred during capture: ' + error.code;
        navigator.notification.alert(msg, null, 'Uh oh!');
    }
    
  
</script>
</head> 
<body>
<div data-role="page">
		<div data-role="header">
			<h1>phonegap100.com</h1>
		</div>
		<div data-role="content" >
                <a data-role="button" class="captureAudioBtn" >拍照</a>                 
                <div id="imgcontainer"></div>
                <div id="message"></div>           
       </div>
		<div data-role="footer">
			<h4>phonegap中文网</h4>
		</div>
</div>

</body>
</html>
